import subprocess
ipadr = input("请输入要检查的ip")
p = open("ipadrs.txt","a+",encoding = "utf-8")
b=subprocess.run("ping -c 1 {}".format(ipadr) ,shell = True)
if b.returncode == 0:
    print("ip存活，正在被使用")
    p.write(ipadr+"已被使用"+'\n')
else:
    print("ip未被使用")

